iOS Soap Web Service Hata
Merhaba arkadaşlar,
Resimde görmüş olduğunuz hatayı alıyorum kodda herhangi bir hata vermiyor Info.plist dosyasında bir izin mi vermem gerekli yardımcılarınız için şimdiden teşekkür ederim
Kodlar :
import UIKit
//Step 1: Add protocol names that we will be delegating.
class ViewController: UIViewController, UITextFieldDelegate, NSURLConnectionDelegate, NSXMLParserDelegate {
var mutableData:NSMutableData = NSMutableData()
var currentElementName:NSString = ""
@IBOutlet var txtCelsius : UITextField!
@IBOutlet var txtFahrenheit : UITextField!
@IBAction func actionConvert(sender : AnyObject) {
//let celcius = txtCelsius.text!
guard let celcius = txtCelsius.text where celcius != "" else {
return
}
let soapMessage = "\(celcius)"
let urlString = "http://www.w3schools.com/xml/tempconvert.asmx?op=CelsiusToFahrenheit"
let url = NSURL(string: urlString)
let theRequest = NSMutableURLRequest(URL: url!)
//var msgLength = String(countElements(soapMessage))
theRequest.addValue("text/xml; charset=utf-8", forHTTPHeaderField: "Content-Type")
theRequest.addValue("/(soapMessage.characters.count)", forHTTPHeaderField: "Content-Length")
theRequest.HTTPMethod = "POST"
theRequest.HTTPBody = soapMessage.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) // or false
let connection = NSURLConnection(request: theRequest, delegate: self, startImmediately: true)
connection!.start()
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// NSURLConnectionDelegate
// NSURL
func connection(connection: NSURLConnection!, didReceiveResponse response: NSURLResponse!) {
mutableData.length = 0;
}
func connection(connection: NSURLConnection!, didReceiveData data: NSData!) {
mutableData.appendData(data)
}
func connectionDidFinishLoading(connection: NSURLConnection!) {
let xmlParser = NSXMLParser(data: mutableData)
xmlParser.delegate = self
xmlParser.parse()
xmlParser.shouldResolveExternalEntities = true
}
// NSXMLParserDelegate
func parser(parser: NSXMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String]) {
currentElementName = elementName
}
func parser(parser: NSXMLParser, foundCharacters string: String) {
//!!!if currentElementName == “CelsiusToFahrenheitResult” {
txtFahrenheit.text = string
//}
}
}